#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

from pymongo import MongoClient


# 连接MongoDB
def InitMongoDB():
    MONGODB_HOST = '10.188.188.22'
    MONGODB_PORT = 27017
    MONGODB_DB_NAME = 'pmc'
    MONGODB_COLLECTION_NAME = 'filelist'
    connection = MongoClient(MONGODB_HOST, MONGODB_PORT)
    db = connection[MONGODB_DB_NAME]
    collection = db[MONGODB_COLLECTION_NAME]
    return connection, collection


# 关闭MongoDB
def CloseMongoDB(MongoDB_Connection):
    MongoDB_Connection.close()


if __name__ == "__main__":
    MongoDB_Connection, MongoDB_Collection = InitMongoDB()

    results = MongoDB_Collection.distinct("time_in")

    for result in results:
        print str(result)

    CloseMongoDB(MongoDB_Connection)
